﻿using Hangfire;
using Hangfire.Dashboard;
using Microsoft.Owin;
using Owin;
using ServiceMs.Base;
using ServiceMs.Filter;
using System.Configuration;

[assembly: OwinStartup(typeof(ServiceMs.Startup))]
namespace ServiceMs
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            LogHelper.WriteLog("服务初始化开始");
            GlobalConfiguration.Configuration.UseSqlServerStorage("HangFireDataBase");

            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute() { Attempts = 4 });//设置错误重试次数

            var options = new DashboardOptions { Authorization = new IDashboardAuthorizationFilter[] { new DashboardAuthorizationFilter() } };
            app.UseHangfireDashboard("/hangfire", options);

            //app.UseHangfireDashboard("/hangfire");
            app.UseHangfireServer();
            LogHelper.WriteLog("服务初始化结束");

            ServiceHandle.InitServices();
        }
    }
}